package lab03.test11;

import java.sql.*;

public class Test11 {
    public static void main(String[] args) {
        Connection connection=null;
        Statement statement= null;
        ResultSet resultSet=null;
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            try {
                connection= DriverManager.getConnection("jdbc:mysql://" +
                                "localhost:3306/java_2017?serverTimezone=UTC",
                        "root",
                        "123");
            } catch (SQLException e) {
                e.printStackTrace();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        try {
            connection= (Connection) connection.createStatement();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            statement.executeUpdate("insert into t_users(id,usename,password,register_datetime)" +
                        "values (1,'admin','admin',192312312123)");
            statement.executeUpdate( "insert into t_users(id,usename,password,register_datetime)" +
                    "values (2,'chen','12346',123123213123)");
        } catch (SQLException e) {
            e.printStackTrace();
        }

        try {
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
